<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
	xmlns:layout="http://www.ultraq.net.nz/web/thymeleaf/layout">
<head th:include="inc/examHeader::header">
</head>
	<body>
		<!--返回-->
		<div class="back" onclick="changeMain('/paperManager/wtake?timestamp='+new Date().getTime())"><img src="/exam/images/back.png" /></div>
		<div th:include="header :: header"></div>
		<div class="header-title" th:if="${SJK.paperId!=null}" th:each="SJK,iterStat : ${sj}">
			<span th:text="${SJK.examName}">考试1</span>
		</div>
		<div class="spare-a">
			<div class="save-bg"><a href="#" class="spare-tj" onclick="saveAnswer()" id="submitExam">提 交</a></div>
			<div class="spare-add">
				<div class="nottake-a" th:if="${SJK.paperId!=null}" th:each="SJK,iterStat : ${sj}">
					<span th:text="'姓名：'+${session.user.userName}">总时间：60.0分钟</span>
					<span th:if="${SJK.examType=='考试试卷'}" id="totalSc" th:text="'总分：'+${SJK.totalSc}"></span>
					<span id="zsj1" th:text="${SJK.totalTime}" style="display:none"></span>
					<span id="zsj" th:text="'总时间：'+${SJK.totalTime}+'分钟'"></span>
					<span id="ShowDiv"></span>
					<a href="#" class="spare-tj" id="manual-add">手动翻题</a><a href="#" class="spare-tj" id="automatic-add">自动翻题</a>
				</div>
				 <input type="text"  readonly="readonly"  style="display:none"   id="spendTime"/> 
				 <form id="userAnswer" method="post">
				<div class="nottake-b" th:if="${SJK.questionType=='单选题'}"   th:each="SJK,iterStat : ${sj}">
					<div class="paper-d-title"  th:text="${iterStat.count}+'、'+${SJK.questionTypeTitle}">一、单选题（每小题5.0分，共25.0分）</div>
					<div class="nottake-ba" th:each="chK,iterStat1 : ${SJK.ch}" >
						<div class="nottake-ba-title"  th:text="'('+${iterStat1.count}+')、'+${chK.content}">1、涉密场所应当按照国家有关规定经相关部门的安全技术检测，与境外机构、人员住所保持（）的安全距离。</div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.a)} ? 'none': 'block')} + ''">
					    	<a th:text="'A.'+${chK.a}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'1'"  value="A" style="display:none"/>
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.b)} ? 'none': 'block')} + ''">
					    	<a th:text="'B.'+${chK.b}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'2'"  value="B" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.c)} ? 'none': 'block')} + ''">
					    	<a th:text="'C.'+${chK.c}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'3'"  value="C" style="display:none" />
					    	<div class="documentation-check"></div> 
					    </div>					    
					     <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.d)} ? 'none': 'block')} + ''">
					    	<a th:text="'D.'+${chK.d}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'4'"  value="D" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb" th:style="'display:'+@{(${#strings.isEmpty(chK.e)} ? 'none': 'block')} + ''">
					    	<a th:text="'E.'+${chK.e}"></a>
					    	<input th:name="${chK.id}" th:id="${chK.id}+'5'"  value="E" style="display:none" />
					    	<div class="documentation-check"></div> 
					    </div>
					</div>
					</div>
				<div class="nottake-b" th:if="${SJK.questionType=='多选题'}"  th:each="SJK,iterStat : ${sj}">
					<div class="paper-d-title" th:text="${iterStat.count}+'、'+${SJK.questionTypeTitle}">二、多选题（每小题5.0分，共25.0分）</div>
					<div class="nottake-ba" th:each="chK,iterStat1 : ${SJK.ch}">
						<div class="nottake-ba-title" th:text="'('+${iterStat1.count}+')、'+${chK.content}">1、高校保密责任主体是。</div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.a)} ? 'none': 'block')} + ''">
					    	<a th:text="'A.'+${chK.a}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="A" style="display:none" />
					    	<div class="documentation-check" ></div>
					    </div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.b)} ? 'none': 'block')} + ''">
					    	<a th:text="'B.'+${chK.b}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="B" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.c)} ? 'none': 'block')} + ''">
					    	<a th:text="'C.'+${chK.c}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="C" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>					    
					     <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.d)} ? 'none': 'block')} + ''">
					    	<a th:text="'D.'+${chK.d}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="D" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bc" th:style="'display:'+@{(${#strings.isEmpty(chK.e)} ? 'none': 'block')} + ''">
					    	<a th:text="'E.'+${chK.e}"></a>
					    	<input th:name="${chK.id}"  th:id="${chK.id}" value="E" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					</div>
					</div>
				<div class="nottake-b" th:if="${SJK.questionType=='判断题'}"  th:each="SJK,iterStat : ${sj}">
					<div class="paper-d-title" th:text="${iterStat.count}+'、'+${SJK.questionTypeTitle}">三、判断题（每小题5.0分，共25.0分）</div>
					<div class="nottake-ba" th:each="chK,iterStat1 : ${SJK.ch}">
						<div class="nottake-ba-title" th:text="'('+${iterStat1.count}+')、'+${chK.content}">1、“业务工作谁主管，保密工作谁负责”是保密工作的重要原则。</div>
					    <div class="nottake-bb">
					    	A.正确
					    	<input th:name="${chK.id}" th:id="${chK.id}+'1'"  value="A" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					    <div class="nottake-bb">					    	
					        B.错误
					        <input th:name="${chK.id}" th:id="${chK.id}+'2'"  value="B" style="display:none" />
					    	<div class="documentation-check"></div>
					    </div>
					</div>					
					</div>
					<div class="nottake-b" th:if="${SJK.questionType=='问答题'}"  th:each="SJK,iterStat : ${sj}">
						<div class="paper-d-title" th:text="${iterStat.count}+'、'+${SJK.questionTypeTitle}">四、简答题（每小题5.0分，共25.0分）</div>
						<div class="nottake-ba" th:each="chK,iterStat1 : ${SJK.ch}">
							<div class="nottake-ba-title" th:text="'('+${iterStat1.count}+')、'+${chK.content}">1、“业务工作谁主管，保密工作谁负责”是保密工作的重要原则。</div>
						    <div class="nottake-bd">
						    	<textarea class="nottake-textarea" th:name="${chK.id}"></textarea>
						    </div>
						</div>
					</div>
					<div class="nottake-b" th:if="${SJK.questionType=='填空题'}"  th:each="SJK,iterStat : ${sj}">
						<div class="paper-d-title" th:text="${iterStat.count}+'、'+${SJK.questionTypeTitle}">四、简答题（每小题5.0分，共25.0分）</div>
						<div class="nottake-ba" th:each="chK,iterStat1 : ${SJK.ch}">
							<div class="nottake-ba-title" th:text="'('+${iterStat1.count}+')、'+${chK.content}">1、“业务工作谁主管，保密工作谁负责”是保密工作的重要原则。</div>
						    <div class="nottake-bd">
						    	<textarea class="nottake-textarea" th:name="${chK.id}"></textarea>
						    </div>
						</div>
					</div>
					
					</form>
				</div>
			</div>
	</body>
	<script th:inline="javascript">  
/*<![CDATA[*/  
    var examType=[[${examType}]];
    var questionSize=[[${questionSize}]];
    var totalTime=[[${totalTime}]];
    /* if(examType=="考试试卷"){
  	 $("#automatic-add").attr('style',"");
    }else{
     $("#automatic-add").attr('style',"display: none"); 
    } */
    var paperId=[[${#httpServletRequest.getParameter('paperId')}]];
   
	var m=parseInt($("#zsj1").text());
	var s = 60;
	function showtime(){
		var k=m-1;	
		
		if(document.getElementById('ShowDiv')==null){
			 clearInterval(settime);
		}else{
			document.getElementById('ShowDiv').innerHTML = "剩余时间 :"+k+":"+s;
		}		
		$("#spendTime").val(k);
	    s = s-1;
	    if(s==0){
	        m = m -1;
	        s = 60;
	    }
	    if(m==0){
	    	alert("考试时间到！");
	    	document.getElementById("submitExam").click();
	    }	
	}
	 clearInterval(settime);
	 var settime = setInterval(function(){
	    showtime();
	},1000);	
    
    $(function(){
		$('#automatic-add').on('click', function(e) {
	        e.preventDefault();
	        var diag = new $.Zebra_Dialog({
	            source:  {'ajax': 'automatic.html'},
	            width:460,
	            title:'自动翻题',
	            buttons: [{caption:'确认',
	            	       callback: function() {
	            	    	   var autoTime=getAutoTime();
	            	    	   if(autoTime!=0){
	            	    		   if(questionSize*autoTime<=totalTime){
			            			   window.location.href="/examReport/wtake-xq2?paperId="+paperId+"&autoTime="+getAutoTime()+"&totalTime="+m;
			            	    	   } else{
			            	    		   $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">设定时间过大，请重新输入或修改试卷时间</div></div>', {
		            	     	            'title':'提示',
		            	     	            'buttons':['确定']
		            	     	         });
			            	    		   }
	            	    		   }else{
	            	    			   $.Zebra_Dialog('<div class="prompt"><div class="warning-icon"></div><div class="success-title">设定时间不能为零，请重新输入或修改试卷时间</div></div>', {
		            	     	            'title':'提示',
		            	     	            'buttons':['确定']
		            	     	         });
	            	    		   }
	            	    	   
	        				}
	            		} ]
	        });
	        
	    });
	}) 

	$('#manual-add').on('click', function() {
		window.location.href="/examReport/wtake-xq2?paperId="+paperId+"&totalTime="+m;
	        });
    function saveAnswer(){  
    	alert("正在提交，请稍后...");
    	$($(".nottake-bb")).each(function(){
    		if(!$(this).is(".active")){
		        $(this).children("input").remove();
    		}
    	});
    	$($(".nottake-bc")).each(function(){
    		if(!$(this).is(".active")){
		        $(this).children("input").remove();
    		}
    	});
    	$('#submitExam').attr('disabled','disabled');
    	clearInterval(settime);
    	var m=parseInt($("#zsj1").text())-parseInt($("#spendTime").val());  
    	totalSc=$("#totalSc").text();
    	$.ajax({
    		type:"POST",
    		data:$('#userAnswer').serialize(),
    		url:"/examReport/saveAnswer?paperId="+paperId+"&spendTime="+m,
    		success:function(data){
    			window.location.href="/examReport/take-xq2?paperId="+paperId;
    		}
    	}); 
    }
    /*]]>*/  
</script>
</html>
